package model

import "time"

type Product struct {
	ProductId  int32     `gorm:"column:product_id;type:int;primaryKey;not null;" json:"product_id"`
	BrandId    int32     `gorm:"column:brand_id;type:int;default:NULL;" json:"brand_id"`
	CategoryId int32     `gorm:"column:category_id;type:int;default:NULL;" json:"category_id"`
	Name       string    `gorm:"column:name;type:varchar(255);default:NULL;" json:"name"`
	Price      float32   `gorm:"column:price;type:float;default:NULL;" json:"price"`
	Stock      int32     `gorm:"column:stock;type:int;default:NULL;" json:"stock"`
	ImgUrl     string    `gorm:"column:img_url;type:varchar(255);default:NULL;" json:"img_url"`
	Status     string    `gorm:"column:status;type:varchar(10);default:NULL;" json:"status"`
	CreateTime time.Time `gorm:"column:create_time;type:datetime(3);default:NULL;" json:"create_time"`
}
type ProductData struct {
	ProductId  int32     `json:"productId" form:"productId" gorm:"primarykey;column:product_id;"`            //商品id
	BrandId    int32     `json:"brandId" form:"brandId" gorm:"column:brand_id;" binding:"required"`          //品牌
	CategoryId int32     `json:"categoryId" form:"categoryId" gorm:"column:category_id;" binding:"required"` //分类
	Name       string    `json:"name" form:"name" gorm:"column:name;size:255;" binding:"required"`           //商品名
	Price      float64   `json:"price" form:"price" gorm:"column:price;size:10;" binding:"required"`         //价格
	Stock      int32     `json:"stock" form:"stock" gorm:"column:stock;" binding:"required"`                 //库存
	ImgUrl     string    `json:"imgUrl" form:"imgUrl" gorm:"column:img_url;size:255;"`                       //图片
	Status     string    `json:"status" form:"status" gorm:"column:status;size:10;" binding:"required"`      //状态
	CreateTime time.Time `json:"createTime" form:"createTime" gorm:"column:create_time;"`                    //新建时间
	Brand      string    `json:"brand" form:"brand" gorm:"column:brand;"`                                    //品牌
	Category   string    `json:"category" form:"category" gorm:"column:category;"`                           //分类
}

func (Product) TableName() string {
	return "product"
}
